<template>
  <div>
    <HomePanel ref="target" title="新鲜好物" subTitle="新鲜出炉 品质靠谱">
      <ul>
        <li v-for="item in getHomeList" :key="item.id">
          <img v-defaultImg="item.picture" alt="" />
          <h2>{{ item.title }}</h2>
          <p>{{ item.alt }}</p>
        </li>
      </ul>
    </HomePanel>
  </div>
</template>
<script>
import HomePanel from './home-panel.vue'
import { ref } from 'vue'
import { reqFindHot } from '@/api/home'
import { vueuse } from '@/compositions'

export default {
  name: 'HomeHot',
  components: {
    HomePanel
  },
  setup () {
    const getHomeList = ref([])
    const getHomeHot = async () => {
      const res = await reqFindHot()
      // eslint-disable-next-line eqeqeq
      // if (res.code == 1) {
      getHomeList.value = res.result
      // }
    }
    const target = ref(null)
    vueuse(target, getHomeHot)
    return { target, getHomeList }
  }
}
</script>
<style lang="less" scoped>
.move:hover {
  color: #27bb9a;
}
ul {
  display: flex;
  justify-content: space-between;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    text-align: center;
    font-size: 22px;
    img {
      width: 100%;
    }
    h2 {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      padding: 0 30px;
      font-size: 22px;
      margin: 10px 0;
      font-weight: 500;
    }
    p {
      font-size: 18px;
      color: #999;
    }
  }
}
</style>
